package com.chen.Dome2API;

public class APIDome1 {
    //main方法本来就有一条线程
    public static void main(String[] args) {

        Thread mt = new MyThread("1号");
       // mt.setName("1号");
        mt.start();
        Thread mt2 = new MyThread("2号");
        //mt2.setName("2号");
        mt2.start();
        Thread m = Thread.currentThread();//获取当前线程
        System.out.println(m.getName());
    }
}

class MyThread extends Thread {
    //使用有参构造器设置线程名称
    public MyThread(String name) {
        super(name);
    }
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {

            System.out.println("子线程"+Thread.currentThread().getName()+"在跑" + i);

        }
    }

}
